home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
lptreset.arc
/
LPTRESET.C
next >
Wrap
Text File
|
1987-05-12
|
2KB
|
87 lines
/* Last revision: May 12, 1987 at 17:36 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Program lptreset */
/* */
/* usage: lptreset [printer] where */
/* Optional printer is 1, 2 or 3 for LPT1:, LPT2: or LPT3: */
/* Default resets LPT1: */
/* */
/* Initialize LPT1:, LPT2: or LPT3:. */
/* Return ERRORLEVEL 0 if ok, 1 if failure, which either means a bad */
/* command line or (probably) the printer is off line. */
/* */
/* Compiled with Lattice C, Version 3.10 */
/* */
/* Lew Paper */
/* Copyright (c) 1987 Lew Paper */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <dos.h>
static char copyrit[] = "Copyright (c) 1987 Lew Paper\n\n";
void usage()
{
fputs("usage: lptreset [printer] where\n", stderr);
fputs(" Optional printer is 1, 2 or 3 for LPT1, LPT2 or LPT3\n",
stderr);
fputs(" Default resets LPT1:\n", stderr);
fputs(copyrit, stderr);
exit(1);
}
main(argc, argv)
int argc;
char *argv[];
{
int printer;
union REGS reg;
switch (argc)
{
case 1:
printer = '1';
break;
case 2:
switch (*argv[1])
{
case '1':
case '2':
case '3':
printer = *argv[1];
break;
default:
usage();
break;
}
break;
default:
usage();
break;
}
reg.h.ah = 1;
reg.x.dx = printer - '1';
(void) int86(0x17, ®, ®);
if(reg.h.ah & 0x10)
{
fprintf(stderr, "Initialized LPT%c: Printer Port\n%s", printer,
copyrit);
exit(0);
}
else
{
fprintf(stderr, "Unable to initialize LPT%c: Printer Port\n%s",
printer, copyrit);
exit(1);
}
}